"""author: wenyao
   data: 2021/12/10
   project: cjh
"""
#
class  Animal():
    species = "Animal"
    count = 0
    def __init__(self):
        self.name = "animal"
        self.age = 10
        Animal.count += 1
        print("初始化Animal...")
    def breath(self):
        print("i ca breath")
    def eat(self):
        print("i can eat")

class Person(Animal):
    species = "Person"  #重写了父类的属性

class Dog(Animal):
    def __init__(self):
        print("i am dog")
    def eat(self):
        print("dog is eating....")
class Pig(Animal):
    count = 0
    def __init__(self):
        #最好放在子类定义的前面
        super().__init__()  #子类访问父类的方法属性
        # self.name = "animal"
        # Animal.count += 1
        # print("初始化Animal...")
        #
        # self.name = "pig"
        # Pig.count += 1
        # print("初始化pig。。。。")

        #super().__init__()
        # self.name = "animal"
        # Animal.count += 1
        # print("初始化Animal...")

# animal = Animal()
# print(Animal.count, animal.count)
# print("实例化person".center(50,"*"))
# p = Person()
#继承父类的属性和方法
#对象属性查找，现在对象实例空间查找， 没有就去类空间查找
#类空间没有就去父类空间查找，层层递归往上查找
# print(p.count, p.species, Person.count, p.name)
# print("实例化dog".center(50,"*"))
# d = Dog()
# # print(d.name)
# d.eat()
# print("实例化pig".center(50,"*"))
# pig = Pig()
# print(pig.count, pig.name, animal.count)

#类和实例的关系判断
# print("类和实例的关系判断".center(50,"*"))
# print(isinstance(p,Person), isinstance(p, Animal))
# print(type(p))
# print(Pig.__base__)